#!/bin/sh -
#
# build script for 1.1
#
# If it's given a buildname it creates a subdirectory and places a build in it,
# otherwise it just creates the docs and class files.
#

JDK11PATH=/opt/jdk1.1.8   # JDK 1.1 location

base=$1
version=`echo $base | sed -e "s/\([0-9]\)\([0-9a-z]*\)/\1.\2/"`

WINDOWTITLE="Bouncy Castle Cryptography $version API Specification"
HEADER="<b>Bouncy Castle Cryptography $version</b>"
DOCTITLE="Bouncy Castle $version API Specification"

if test "$base" != "" -a ! -d lcrypto-jdk11-$base
then
    echo "making lightweight release"

    mkdir lcrypto-jdk11-$base
    tar cf - index.html LICENSE.html CONTRIBUTORS.html releasenotes.html specifications.html src/org/bouncycastle/LICENSE.java src/org/bouncycastle/math src/org/bouncycastle/crypto src/org/bouncycastle/util src/org/bouncycastle/asn1 | (cd lcrypto-jdk11-$base; tar xf -)
    (cd test; tar cf - src/org/bouncycastle/crypto src/org/bouncycastle/util src/org/bouncycastle/asn1) | (cd lcrypto-jdk11-$base; tar xf -)
    (cd jdk1.1; tar cf - org/bouncycastle/crypto org/bouncycastle/asn1) | (cd lcrypto-jdk11-$base/src; tar xf -)
    (cd jdk1.3; tar cf - org/bouncycastle/asn1) | (cd lcrypto-jdk11-$base/src; tar xf -)
    rm -f lcrypto-jdk11-$base/src/org/bouncycastle/crypto/test/AESVector*

    (
        cd lcrypto-jdk11-$base;
        rm -rf src/org/bouncycastle/math/ntru
        rm -rf src/org/bouncycastle/crypto/test/ntru
        rm -rf src/org/bouncycastle/crypto/*/NTRU*
        rm -rf src/org/bouncycastle/crypto/*/BitStringTest*
        rm -rf src/org/bouncycastle/crypto/*/IndexGenerator*
        find src -name AllTests.java -exec rm {} \;
        rm src/org/bouncycastle/asn1/test/GetInstanceTest.java
        rm src/org/bouncycastle/asn1/test/ASN1SequenceParserTest.java
        rm src/org/bouncycastle/asn1/test/OctetStringTest.java
        rm src/org/bouncycastle/asn1/test/ParseTest.java
        rm src/org/bouncycastle/crypto/test/GCMReorderTest.java
        rm src/org/bouncycastle/util/CollectionStore.java
        rm src/org/bouncycastle/util/Store.java
        rm src/org/bouncycastle/util/StoreException.java
        rm src/org/bouncycastle/util/Selector.java
        rm src/org/bouncycastle/util/StreamParser.java
        rm src/org/bouncycastle/util/StreamParsingException.java
        rm src/org/bouncycastle/util/utiltest/IPTest.java

        mkdir classes; mkdir docs;
        (2>&1 javadoc -windowtitle "$WINDOWTITLE" -doctitle "$DOCTITLE" \
            -header "$HEADER" \
            -classpath classes \
            -group "Lightweight Crypto Packages" "org.bouncycastle.crypto*" \
            -group "ASN.1 Support Packages" "org.bouncycastle.asn1*" \
            -group "Math Support Packages" "org.bouncycastle.math*" \
            -group "Utility Packages" "org.bouncycastle.util*" \
            -d docs -sourcepath src \
            org.bouncycastle.asn1 \
            org.bouncycastle.asn1.cmp \
            org.bouncycastle.asn1.cms \
            org.bouncycastle.asn1.cryptopro \
            org.bouncycastle.asn1.esf \
            org.bouncycastle.asn1.ess \
            org.bouncycastle.asn1.gnu \
            org.bouncycastle.asn1.iana \
            org.bouncycastle.asn1.icao \
            org.bouncycastle.asn1.misc \
            org.bouncycastle.asn1.mozilla \
            org.bouncycastle.asn1.nist \
            org.bouncycastle.asn1.ocsp \
            org.bouncycastle.asn1.oiw \
            org.bouncycastle.asn1.pkcs \
            org.bouncycastle.asn1.sec \
            org.bouncycastle.asn1.smime \
            org.bouncycastle.asn1.teletrust \
            org.bouncycastle.asn1.test \
            org.bouncycastle.asn1.tsp \
            org.bouncycastle.asn1.util \
            org.bouncycastle.asn1.x509 \
            org.bouncycastle.asn1.x9 \
            org.bouncycastle.math.ec \
            org.bouncycastle.crypto \
            org.bouncycastle.crypto.agreement \
            org.bouncycastle.crypto.digests \
            org.bouncycastle.crypto.encodings \
            org.bouncycastle.crypto.engines \
            org.bouncycastle.crypto.generators \
            org.bouncycastle.crypto.io \
            org.bouncycastle.crypto.macs \
            org.bouncycastle.crypto.modes \
            org.bouncycastle.crypto.paddings \
            org.bouncycastle.crypto.params \
            org.bouncycastle.crypto.signers \
            org.bouncycastle.crypto.tls \
            org.bouncycastle.crypto.test \
            org.bouncycastle.crypto.examples \
            org.bouncycastle.util.encoders \
            org.bouncycastle.util.test) > /dev/null \

        PATH=$JDK11PATH/bin:$PATH
        export PATH
        JAVA_HOME=$JDK11PATH
        export JAVA_HOME

        echo "compiling"

        (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip *.java ; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */*.java; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */p*/*.java
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */a*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */d*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */e*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */g*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */i*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */m*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */s*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip a*/t*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip c*/t*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip u*/t*/*.java 
javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */u*/*.java )

        echo "lightweight regression test"
        java -mx512m -classpath classes:$JDK11PATH/lib/classes.zip -Dbc.test.data.home=/home/dgh/bc/java/crypto/test/data org.bouncycastle.crypto.test.RegressionTest
    )
    (2>&1 find lcrypto-jdk11-$base -name CVS -exec rm -rf \{\} \; ) > /dev/null
fi

if test "$base" != "" -a ! -d jce-jdk11-$base
then
    echo "making JCE release"

    mkdir jce-jdk11-$base
    tar cf - index.html LICENSE.html CONTRIBUTORS.html releasenotes.html specifications.html src | (cd jce-jdk11-$base; tar xf -)
    (cd jce && tar cf - src | (cd ../jce-jdk11-$base; tar xf -))
    (cd test/src && tar cf - * | (cd ../../jce-jdk11-$base/src; tar xf -))
    (cd test/data && tar cf - org/bouncycastle/asn1 | (cd ../../jce-jdk11-$base/src; tar xf -))
    (cd jdk1.4 && tar cf - * | (cd ../jce-jdk11-$base/src; tar xf -))
    (cd test/jdk1.4 && tar cf - * | (cd ../../jce-jdk11-$base/src; tar xf -))
    (cd jdk1.3 && tar cf - * | (cd ../jce-jdk11-$base/src; tar xf -))
    (cd test/jdk1.3 && tar cf - * | (cd ../../jce-jdk11-$base/src; tar xf -))
    (cd jdk1.2 && tar cf - * | (cd ../jce-jdk11-$base/src; tar xf -))
    (cd jdk1.1 && tar cf - * | (cd ../jce-jdk11-$base/src; tar xf -))

    (
    cd jce-jdk11-$base; mkdir classes; mkdir docs;

    rm -rf src/org/bouncycastle/jce/cert
    rm -rf src/org/bouncycastle/math/ntru
    rm -rf src/org/bouncycastle/crypto/test/ntru
    rm -rf src/org/bouncycastle/crypto/*/NTRU*
    rm -rf src/org/bouncycastle/crypto/*/test
    rm -rf src/org/bouncycastle/crypto/*/IndexGenerator*
    rm src/org/bouncycastle/jcajce/provider/config/*Permission.java
    rm src/org/bouncycastle/jce/provider/test/DHTest.java
    rm src/org/bouncycastle/jce/provider/test/DSATest.java
    rm src/org/bouncycastle/jce/provider/test/ECIESTest.java
    rm src/org/bouncycastle/jce/provider/test/ElGamalTest.java
    rm src/org/bouncycastle/jce/provider/test/NamedCurveTest.java
    rm src/org/bouncycastle/jce/provider/test/PSSTest.java
    rm src/org/bouncycastle/jce/provider/test/NIST*.java
    rm src/org/bouncycastle/jce/provider/test/GOST3410Test.java
    rm src/org/bouncycastle/crypto/test/GCMReorderTest.java
    rm -rf src/org/bouncycastle/asn1/test/GetInstanceTest.java
    rm -rf src/org/bouncycastle/i18n/test
    rm -rf src/org/bouncycastle/i18n/filter/test
    rm -rf src/org/bouncycastle/voms
    rm -rf src/org/bouncycastle/jce/ECPointUtil.java
    rm -rf src/org/bouncycastle/jce/X509LDAP*.java
    rm -rf src/org/bouncycastle/jce/provider/JCEEC5*.java
    rm -rf src/org/bouncycastle/jce/provider/JCEEC*.java
    rm -rf src/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java
    rm -rf src/org/bouncycastle/jce/provider/test/CRL5Test.java
    rm -rf src/org/bouncycastle/jcajce/provider/asymmetric/ec/EC5*.java
    rm -rf src/org/bouncycastle/jce/provider/asymmetric/ec/EC5*.java
    rm -rf src/org/bouncycastle/jce/provider/EC5*.java
    rm -rf src/org/bouncycastle/jce/provider/X509LDAP*.java
    rm -rf src/org/bouncycastle/jce/provider/test/X509LDAP*.java
    rm -rf src/org/bouncycastle/jce/provider/test/ECDSA5Test.java
    rm -rf src/org/bouncycastle/jce/provider/test/ECEncodingTest.java
    rm -rf src/org/bouncycastle/jce/provider/test/ECNRTest.java
    rm -rf src/org/bouncycastle/jce/provider/test/IESTest.java
    rm -rf src/org/bouncycastle/jce/provider/test/AttrCertTest.java
    rm -rf src/org/bouncycastle/jce/provider/test/PKIXPolicyMappingTest.java
    rm -rf src/org/bouncycastle/jce/provider/test/nist
    rm -rf src/org/bouncycastle/jce/provider/test/rsa3
    rm -rf src/org/bouncycastle/jce/spec/ECNamedCurveSpec.java
    rm -rf src/org/bouncycastle/mail
    rm -rf src/org/bouncycastle/math/ec/test
    rm -rf src/org/bouncycastle/cms
    rm -rf src/org/bouncycastle/ocsp
    rm -rf src/org/bouncycastle/eac
    rm -rf src/org/bouncycastle/cert
    rm -rf src/org/bouncycastle/bcpg
    rm -rf src/org/bouncycastle/pkcs
    rm -rf src/org/bouncycastle/operator
    rm -rf src/org/bouncycastle/openpgp
    rm -rf src/org/bouncycastle/openssl
    rm -rf src/org/bouncycastle/mozilla
    rm -rf src/org/bouncycastle/voms
    rm -rf src/org/bouncycastle/sasn1
    rm -rf src/org/bouncycastle/tsp
    rm -rf src/org/bouncycastle/util/encoders/test
    rm src/org/bouncycastle/util/utiltest/IPTest.java
    rm -rf src/org/bouncycastle/x509/PKIXCertPathReviewer.java
    rm -rf src/org/bouncycastle/x509/CertPathReviewerException.java
    rm -rf src/org/bouncycastle/x509/ExtendedPKIX*.java
    rm -rf src/org/bouncycastle/x509/util/LDAPStoreHelper.java
    rm -rf src/org/bouncycastle/jce/provider/PKIXAttrCert*.java
    rm -rf src/org/bouncycastle/jce/provider/PKIXNameConstraints*.java
    rm -rf src/org/bouncycastle/jce/provider/test/PKIXNameConstraintsTest.java
    rm -rf src/org/bouncycastle/jce/provider/test/AttrCertSelectorTest.java
    rm -rf src/org/bouncycastle/jce/provider/test/MQVTest.java
    rm -rf src/org/bouncycastle/x509/ExtendedPKIX*.java
    rm -rf src/org/bouncycastle/jce/provider/PKIXCRL*.java
    rm -rf src/org/bouncycastle/jce/provider/RFC3281*.java
    rm -rf src/org/bouncycastle/jce/provider/JDKPKCS12StoreParameter.java
    rm -rf src/org/bouncycastle/jce/provider/CertPathValidatorUtilities.java
    rm -rf src/org/bouncycastle/jce/ProviderConfigurationPermission.java
    rm -rf src/org/bouncycastle/jce/provider/X509StoreLDAPAttrCerts.java
    rm -rf src/org/bouncycastle/jce/provider/X509StoreLDAPCertPairs.java
    rm -rf src/org/bouncycastle/jce/provider/X509StoreLDAPCerts.java
    rm -rf src/org/bouncycastle/jce/provider/X509StoreLDAPCRLs.java
    rm -rf src/org/bouncycastle/jce/provider/PKIXNameConstraint*.java
    rm -rf src/org/bouncycastle/jce/exception
    rm -rf src/org/bouncycastle/openssl/test/WriterTest.java
    find src -name AllTests.java -exec rm {} \;
    rm src/org/bouncycastle/asn1/test/ASN1SequenceParserTest.java
    rm src/org/bouncycastle/asn1/test/OctetStringTest.java
    rm src/org/bouncycastle/asn1/test/ParseTest.java
    rm src/org/bouncycastle/jce/provider/test/ImplicitlyCaTest.java
    rm src/org/bouncycastle/jce/provider/test/X509StoreTest.java
    rm -rf src/org/bouncycastle/crypto/tls/test

    (2>&1 javadoc -windowtitle "$WINDOWTITLE" -doctitle "$DOCTITLE" \
        -header "$HEADER" \
        -group "Cleanroom JCE" "javax.crypto*" \
        -group "JCE Utility and Extension Packages" "org.bouncycastle.jce*" \
        -group "OCSP Support Packages" "org.bouncycastle.ocsp*" \
        -group "ASN.1 Support Packages" "org.bouncycastle.asn1*" \
        -group "Lightweight Crypto Packages" "org.bouncycastle.crypto*" \
        -group "Utility Packages" "org.bouncycastle.util*:org.bouncycastle.math*" \
        -group "JCE Provider and Test Classes" "org.bouncycastle.jce.provider*" \
        -classpath classes \
        -d docs -sourcepath src \
        java.lang \
        java.security \
        java.security.cert \
        java.security.interfaces \
        java.security.spec \
        java.util \
        javax.crypto  \
        javax.crypto.interfaces \
        javax.crypto.spec \
        org.bouncycastle.jce \
        org.bouncycastle.asn1 \
        org.bouncycastle.asn1.cmp \
        org.bouncycastle.asn1.cms \
        org.bouncycastle.asn1.cryptopro \
        org.bouncycastle.asn1.esf \
        org.bouncycastle.asn1.ess \
        org.bouncycastle.asn1.gnu \
        org.bouncycastle.asn1.iana \
        org.bouncycastle.asn1.icao \
        org.bouncycastle.asn1.misc \
        org.bouncycastle.asn1.mozilla \
        org.bouncycastle.asn1.nist \
        org.bouncycastle.asn1.ocsp \
        org.bouncycastle.asn1.oiw \
        org.bouncycastle.asn1.pkcs \
        org.bouncycastle.asn1.sec \
        org.bouncycastle.asn1.smime \
        org.bouncycastle.asn1.teletrust \
        org.bouncycastle.asn1.test \
        org.bouncycastle.asn1.tsp \
        org.bouncycastle.asn1.util \
        org.bouncycastle.asn1.x509 \
        org.bouncycastle.asn1.x9 \
        org.bouncycastle.math.ec \
        org.bouncycastle.crypto \
        org.bouncycastle.crypto.agreement \
        org.bouncycastle.crypto.digests \
        org.bouncycastle.crypto.encodings \
        org.bouncycastle.crypto.engines \
        org.bouncycastle.crypto.generators \
        org.bouncycastle.crypto.io \
        org.bouncycastle.crypto.macs \
        org.bouncycastle.crypto.modes \
        org.bouncycastle.crypto.paddings \
        org.bouncycastle.crypto.params \
        org.bouncycastle.crypto.signers \
        org.bouncycastle.crypto.test \
        org.bouncycastle.crypto.tls \
        org.bouncycastle.crypto.examples \
        org.bouncycastle.jce.interfaces \
        org.bouncycastle.jce.spec \
        org.bouncycastle.jce.examples \
        org.bouncycastle.jce.provider \
        org.bouncycastle.jce.provider.symmetric \
        org.bouncycastle.jce.provider.asymmetric \
        org.bouncycastle.jce.provider.asymmetric.ec \
        org.bouncycastle.jce.provider.test \
        org.bouncycastle.x509 \
        org.bouncycastle.x509.examples \
        org.bouncycastle.x509.extension \
        org.bouncycastle.ocsp \
        org.bouncycastle.ocsp.test \
        org.bouncycastle.util.encoders \
        org.bouncycastle.util.test) > /dev/null \

    PATH=$JDK11PATH/bin:$PATH
    export PATH
    JAVA_HOME=$JDK11PATH
    export JAVA_HOME

    echo "compiling"

    (cd src/java/; javac -d ../../classes -classpath ../../classes:../../src:$JDK11PATH/lib/classes.zip */*.java */*/*.java )
    (cd src/javax/crypto; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip *.java */*.java)

    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip asn1/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip crypto/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip *.java [bdefghijklmnopqrstuv]*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip asn1/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip crypto/[ade]*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip crypto/[gimpsu]*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip crypto/t*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip jcajce/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip jcajce/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip jcajce/*/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip jcajce/*/*/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip jce/*/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip jce/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip util/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip */*/*/*.java)
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:$JDK11PATH/lib/classes.zip x509/*.java x509/*/*.java)

    rm -rf classes/org/bouncycastle/crypto/test

                                                                                                         
    echo "provider regression test"
    java -classpath classes:$JDK11PATH/lib/classes.zip org.bouncycastle.jce.provider.test.RegressionTest
    java -classpath classes:$JDK11PATH/lib/classes.zip org.bouncycastle.asn1.test.RegressionTest
    )

    ( 2>&1 find jce-jdk11-$base -name CVS -exec rm -rf \{\} \;) > /dev/null
fi

if test "$base" != ""
then
    echo "making PKIX release"

    mkdir bcpkix-jdk11-$base
    tar cf - index.html LICENSE.html CONTRIBUTORS.html releasenotes.html specifications.html src/org/bouncycastle/cert src/org/bouncycastle/mozilla src/org/bouncycastle/voms src/org/bouncycastle/openssl src/org/bouncycastle/pkcs src/org/bouncycastle/cms  src/org/bouncycastle/eac src/org/bouncycastle/tsp src/org/bouncycastle/operator | (cd bcpkix-jdk11-$base; tar xf -)
    (cd test/src; tar cf - org/bouncycastle/cert org/bouncycastle/ocsp/test/OCSPTestUtil.java org/bouncycastle/tsp | (cd ../../bcpkix-jdk11-$base/src; tar xf -))
    (cd test/jdk1.3; tar cf - org/bouncycastle/cert org/bouncycastle/openssl org/bouncycastle/tsp | (cd ../../bcpkix-jdk11-$base/src; tar xf -))
    (cd jdk1.4; tar cf - org/bouncycastle/cms org/bouncycastle/eac | (cd ../bcpkix-jdk11-$base/src; tar xf -))
    (cd jdk1.3; tar cf - org/bouncycastle/cert org/bouncycastle/openssl org/bouncycastle/pkcs org/bouncycastle/cms org/bouncycastle/eac org/bouncycastle/tsp | (cd ../bcpkix-jdk11-$base/src; tar xf -))
    (cd jdk1.2; tar cf - org/bouncycastle/cert org/bouncycastle/cms | (cd ../bcpkix-jdk11-$base/src; tar xf -))
    (cd jdk1.1; tar cf - org/bouncycastle/cert org/bouncycastle/operator org/bouncycastle/tsp org/bouncycastle/cms | (cd ../bcpkix-jdk11-$base/src; tar xf -))
    (
    cd bcpkix-jdk11-$base; mkdir classes; mkdir docs;

    PATH=$JDK11PATH/bin:$PATH
    export PATH
    JAVA_HOME=$JDK11PATH
    export JAVA_HOME

    rm -rf src/java
    rm -rf src/org/bouncycastle/jce
    rm -rf src/org/bouncycastle/bcpg
    rm -rf src/org/bouncycastle/x509
    rm -rf src/org/bouncycastle/mail
    rm -rf src/org/bouncycastle/openpgp
    rm -rf src/org/bouncycastle/asn1
    rm -rf src/org/bouncycastle/i18n
    rm -rf src/org/bouncycastle/jcajce
    rm -rf src/org/bouncycastle/cert/test/ConverterTest*
    rm -rf src/org/bouncycastle/tsp/test
    rm -rf src/org/bouncycastle/tsp/GenTimeAccuracyUnit*
    rm -rf src/org/bouncycastle/tsp/TimeStampTokenInfoUnit*
    find src -name AllTests.java -exec rm {} \;

    javadoc -windowtitle "$WINDOWTITLE" -doctitle "$DOCTITLE" \
        -header "$HEADER" \
        -group "Basic Signing And Encryption" "org.bouncycastle.operator*" \
        -group "Certificate Generation And Handling Support Packages" "org.bouncycastle.cert*" \
        -group "CMS Support Packages" "org.bouncycastle.cms*" \
        -group "EAC Support Packages" "org.bouncycastle.eac*" \
        -group "TSP Support Packages" "org.bouncycastle.tsp*" \
        -group "PKCS Support Packages" "org.bouncycastle.pkcs*" \
        -group "OpenSSL PEM Support Packages" "org.bouncycastle.openssl*" \
        -classpath classes:../jce-ext-jdk11-146.jar \
        -d docs -sourcepath src \
        org.bouncycastle.openssl \
        org.bouncycastle.voms \
        org.bouncycastle.mozilla \
        org.bouncycastle.pkcs \
        org.bouncycastle.pkcs.bc \
        org.bouncycastle.pkcs.jcajce \
        org.bouncycastle.cert \
        org.bouncycastle.cert.cmp \
        org.bouncycastle.cert.crmf \
        org.bouncycastle.cert.jcajce \
        org.bouncycastle.cert.ocsp \
        org.bouncycastle.cert.selector \
        org.bouncycastle.cms \
        org.bouncycastle.cms.bc \
        org.bouncycastle.cms.jcajce \
        org.bouncycastle.cert.test > /dev/null \


    echo "compiling"

    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip */*.java )
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip */*/*.java )
    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip */*/*/*.java )
     cp ../test/src/org/bouncycastle/openssl/test/*.pem classes/org/bouncycastle/openssl/test
    java -mx512m -classpath ../jce-jdk11-$base/classes:classes:$JDK11PATH/lib/classes.zip org.bouncycastle.cert.test.CertTest
    java -mx512m -classpath ../jce-jdk11-$base/classes:classes:$JDK11PATH/lib/classes.zip org.bouncycastle.cert.test.AttrCertTest
    java -mx512m -classpath ../jce-jdk11-$base/classes:classes:$JDK11PATH/lib/classes.zip org.bouncycastle.cert.test.PKCS10Test
    # java -classpath ../jce-jdk11-$base/classes:classes:$JDK11PATH/lib/classes.zip org.bouncycastle.openssl.test.ReaderTest
     )

     (2>&1 find bcpkix-jdk11-$base -name CVS -exec rm -rf \{\} \;) > /dev/null
fi

if test "$base" != ""
then
    echo "making OpenPGP release"

    mkdir bcpg-jdk11-$base
    tar cf - index.html LICENSE.html CONTRIBUTORS.html releasenotes.html specifications.html src/org/bouncycastle/bcpg src/org/bouncycastle/openpgp | (cd bcpg-jdk11-$base; tar xf -)
    (cd test/src; tar cf - org/bouncycastle/openpgp | (cd ../../bcpg-jdk11-$base/src; tar xf -))
    (cd bzip2 && tar cf - src | (cd ../bcpg-jdk11-$base; tar xf -))
    (cd jdk1.1; tar cf - org/bouncycastle/openpgp | (cd ../bcpg-jdk11-$base/src; tar xf -))
    (
    cd bcpg-jdk11-$base; mkdir classes; mkdir docs;

    PATH=$JDK11PATH/bin:$PATH
    export PATH
    JAVA_HOME=$JDK11PATH
    export JAVA_HOME

    rm src/org/bouncycastle/openpgp/examples/DSAElGamalKeyRingGenerator.java
    rm src/org/bouncycastle/openpgp/examples/test/AllTests.java
    rm -f src/org/bouncycastle/openpgp/test/DSA2Test.java

    javadoc -windowtitle "$WINDOWTITLE" -doctitle "$DOCTITLE" \
        -header "$HEADER" \
        -group "BCPG Support Packages" "org.bouncycastle.bcpg*" \
        -group "OpenPGP Packages" "org.bouncycastle.openpgp*" \
        -classpath classes:../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip \
        -d docs -sourcepath src \
        org.bouncycastle.bcpg \
        org.bouncycastle.bcpg.attr \
        org.bouncycastle.bcpg.sig \
        org.bouncycastle.openpgp \
        org.bouncycastle.openpgp.examples \
        org.bouncycastle.openpgp.operator \
        org.bouncycastle.openpgp.operator.jcajce \
        org.bouncycastle.openpgp.operator.bc \
        org.bouncycastle.openpgp.test > /dev/null \

    rm -rf src/org/bouncycastle/openpgp/test/AllTests.java

    ed src/org/bouncycastle/bcpg/ArmoredOutputStream.java <<%
/@RELEASE_NAME@/s//$version/
w
q
%
    echo "compiling"

    (cd src/org/bouncycastle; javac -d ../../../classes -classpath ../../../classes:../../../src:../../../../jce-jdk11-$base/classes:$JDK11PATH/lib/classes.zip */*.java */*/*.java */*/*/*.java )
    java -mx512m -classpath ../jce-jdk11-$base/classes:classes:$JDK11PATH/lib/classes.zip org.bouncycastle.openpgp.test.RegressionTest
     )

     (2>&1 find bcpg-jdk11-$base -name CVS -exec rm -rf \{\} \;) > /dev/null
fi

